#ifndef _Lemon_EPD_H_
#define _Lemon_EPD_H_

#include "Arduino.h"

#define EPD_W21_MOSI_0 digitalWrite(SDI_Pin, LOW)
#define EPD_W21_MOSI_1 digitalWrite(SDI_Pin, HIGH)

#define EPD_W21_CLK_0 digitalWrite(SCK_Pin, LOW)
#define EPD_W21_CLK_1 digitalWrite(SCK_Pin, HIGH)

#define EPD_W21_CS_0 digitalWrite(CS_Pin, LOW)
#define EPD_W21_CS_1 digitalWrite(CS_Pin, HIGH)

#define EPD_W21_DC_0 digitalWrite(DC_Pin, LOW)
#define EPD_W21_DC_1 digitalWrite(DC_Pin, HIGH)
#define EPD_W21_RST_0 digitalWrite(RES_Pin, LOW)
#define EPD_W21_RST_1 digitalWrite(RES_Pin, HIGH)
#define isEPD_W21_BUSY digitalRead(BUSY_Pin)


// //IO settings
// int BUSY_Pin = 16;
// int RES_Pin = 5;
// int DC_Pin = 4;
// int CS_Pin = 14;
// int SCK_Pin = 12;
// int SDI_Pin = 13;

class Lemon_EPD
{
private:
    //IO settings
    static const int BUSY_Pin = D0;
    static const int RES_Pin = D1;
    static const int DC_Pin = D2;
    static const int CS_Pin = D6;
    static const int SCK_Pin = D5;
    static const int SDI_Pin = D7;

public:
    ////////FUNCTION//////
    Lemon_EPD();
    static void IO_settings();
    static void driver_delay_us(unsigned int xus);
    static void driver_delay_xms(unsigned long xms);
    static void DELAY_S(unsigned int delaytime);
    static void SPI_Delay(unsigned char xrate);
    static void SPI_Write(unsigned char value);
    static void EPD_W21_WriteDATA(unsigned char command);
    static void EPD_W21_WriteCMD(unsigned char command);
    //EPD
    static void EPD_W21_Init();
    static void EPD_init();
    static void PIC_display(const unsigned char *picData_old, const unsigned char *picData_new);
    static void PIC_SPIFFS_display();
    static void EPD_sleep();
    static void EPD_refresh();
    static void lcd_chkstatus();
    static void PIC_display_Clean();
};

#endif
